$(function() {

	$.ajax({
		url : 'http://api.twitter.com/1/statuses/user_timeline.json',
		data : {
			 screen_name : username,
			 count : count					 					 
		},
		dataType : 'jsonp',

		success : function( tweets ) {								
			$.each(tweets, function( i ) {

				var text = tweets[i].text,
					thumb = tweets[0].user.profile_image_url, 
					replace = text.replace(/(http:\/\/.*)/, '<a href="$1" target="_blank">$1</a>'),
					replace = replace.replace(/@([A-Za-z0-9_]+)/, '<a href="http://twitter.com/$1" target="_blank" title="$1">@$1</a>');
			
				container.append('<div class="tweet clearfix"><div class="thumb"><a href="http://twitter.com/'+username+'" target="_blank"><img src="'+thumb+'" alt="'+username+'" height="48" width="48" /></a></div><div class="text"><p>'+replace+'</p></div></div>');				

			});		

			// When done
			$('.loading').remove();
		}
		
	});
});
